home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / timer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  926 b   |  36 lines

  1. #include "bbs.h"
  2.  
  3.  
  4. int OpenTimer(void)
  5. {
  6. int error;
  7.  
  8. if(!(TimerPort = CreatePort(0L,0L)))
  9.     return(TRUE);
  10. if(!(TimerMsg=(struct timerequest *)CreateExtIO(TimerPort,(long)sizeof(struct timerequest))))
  11.     return(TRUE);
  12. TimerMsg->tr_node.io_Message.mn_ReplyPort=TimerPort;
  13. if(error = OpenDevice(TIMERNAME,UNIT_VBLANK,TimerMsg,0L)) return(error);
  14. return(FALSE);
  15. }
  16.  
  17. void SetTimer(ULONG secs, ULONG micros)
  18. {
  19. TimerMsg->tr_node.io_Command = TR_ADDREQUEST; /* add a new timer request */
  20. TimerMsg->tr_time.tv_secs    = secs;          /* seconds */
  21. TimerMsg->tr_time.tv_micro   = micros;        /* microseconds */
  22. TimerMsg->tr_node.io_Message.mn_ReplyPort=TimerPort;
  23. SendIO(TimerMsg);     /* post the request to the timer device */
  24. }
  25.  
  26. void CloseTimer(void)
  27. {
  28. if(TimerMsg)    {
  29.      /*if(!CheckIO(TimerMsg)) AbortIO(TimerMsg);
  30.      WaitIO(TimerMsg);*/
  31.     CloseDevice(TimerMsg);
  32.     DeleteExtIO(TimerMsg);
  33.     if(TimerPort) DeletePort(TimerPort);
  34.     }
  35. }
  36.